package define;

public enum ReferenceType 
{
	E_INT_RT("int"),
	E_DOUBLE_RT("double"),
	E_SHORT_RT("short"),
	E_FLOAT_RT("float"),
	E_UINT_RT("uint"),
	E_USHORT_RT("ushort"),
	E_LONG_RT("long"),
	E_ULONG_RT("ulong"),
	E_LONG_LONG_RT("long long"),
	E_CHAR_RT("char"),
	E_BYTE_RT("byte"),
	E_STRING_RT("string"),
	E_BOOL_RT("bool"),
	
	E_CUSTOM_RT(""),
	E_REFERENCE_RT(""),
	;
	
	private String m_value;
	
	private String[] m_java = {"int", "double", "short", "float", "int", "short", "long", "long", "long", "char", "byte", "String", "boolean"};
	private String[] m_cpp = {"int", "double", "short", "float", "unsigned int", "unsigned short", "long", "unsigned long", "long long", "char", 
			"char", "std::string", "bool"};
	private String[] m_flex = {"int", "Number", "int", "Number", "uint", "uint", "int", "uint", "int", "int",
			"int", "String", "Boolean"};
	
	private ReferenceType(String value)
	{
		m_value = value;
	}
	
	public String getValue()
	{
		return m_value;
	}
	
	public String getJCodeValue(CodeOut co)
	{
		if(this.ordinal() > E_BOOL_RT.ordinal())
		{
			return null;
		}
		switch(co) 
		{
		case E_JAVA_CO:
			return m_java[this.ordinal()];
		case E_CPP_CO:
			return m_cpp[this.ordinal()];
		case E_FLEX_CO:
			return m_flex[this.ordinal()];
		default:
			return null;
		}
	}
	
	public static ReferenceType getReferenceType(String text)
	{
		if(text.charAt(0) == Config.CODE_CUSTOM)
		{
			return E_CUSTOM_RT;
		}
		for(int i = 0, max = E_BOOL_RT.ordinal(); i < max; ++i)
		{
			ReferenceType type = ReferenceType.values()[i];
			if(type.getValue().compareTo(text) == 0)
			{
				return type;
			}
		}
		return E_REFERENCE_RT;
	}
}
